<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>基础语音服务系统</title>
    <link rel="stylesheet" href="./adminlte/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="./common/libs/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="./common/css/style.css" rel="stylesheet">
    <link rel="stylesheet" href="./common/css/login.css" rel="stylesheet">

</head>

<body class="signin" style="color:#000;">

<div class="signinpanel" style="color:rgba(255,255,255,.95)">
    <div class="row">
        <div class="col-sm-7">
            <div class="signin-info">
                <div class="logopanel m-b">
                    <h1>基础语音服务系统</h1>
                </div>
                <br>
                <div class="m-b"></div>
                <h4>欢迎来到<strong>基础语音服务系统</strong></h4>
            </div>
        </div>
        <div class="col-sm-5">
            <form class="loginForm">
                <head>
                    <span><strong>登陆:</strong></span>
                    <span style="float:right">
                        <a class="register"><strong>注册</strong></a>
                    </span>
                </head>
                <p class="m-t-md" id="error" style="color:red;"></p>
                <input name="phone" type="text" class="form-control uname m-b" placeholder="手机号" required="true"/>
                <input name="password" type="password" class="form-control pword m-b" placeholder="密码" required="true"/>
                <div class="checkbox" style="display: flex;justify-content: space-between;align-items: center">
                    <label class="pull-left"><input type="checkbox" id="save" style="transform: translateY(50%);"/>记住我</label>
                    <a href="javascript:void(0);" id="forgetPassword"
                       style="cursor:pointer;text-decoration:none;">忘记密码</a>
                </div>
                <button type="button" id="login" class="btn btn-success btn-block">登录</button>

            </form>
        </div>
    </div>
    <div class="signup-footer">
        <div class="pull-left">
            &copy; 2015 All Rights Reserved.
        </div>
    </div>
</div>


<script src="./adminlte/plugins/jQuery/jQuery-2.2.0.min.js"></script>
<script src="./adminlte/bootstrap/js/bootstrap.min.js"></script>
<script src="./common/js/base-modal.js"></script>
<script src="./common/js/ajax.js"></script>
<script src="./common/js/form.js"></script>
<script src="./common/js/common.js"></script>
<script>
    $("#forgetPassword").click(function () {
        modals.openWin({
            winId: "forgetPasswordWin",
            title: '忘记密码',
            url: "./common/forgetPassword.html",
            showFunc:function () {
                var win=this;
                $(win).find(".modal-footer button:last").click(function () {
                    var param = getFormData($(win).find("form"));
                    var oThis = this;
                    $(oThis).prop("disabled", true);
                    AsyncPost("/user/password", param, function (value) {
                        modals.correct("重置密码成功",function () {
                            modals.closeWin("forgetPasswordWin");
                        })
                        $(oThis).prop("disabled", false);
                    },function (message) {
                        $(oThis).prop("disabled", false);
                    })
                })
            }
        })
    })

    $(".register").click(function () {
        window.location.href = "./register.html";
    })

    if (localStorage.rememberMe && localStorage.rememberMe == "1") {
        $("[name='phone']").val(localStorage.phone);
        $("[name='password']").val(localStorage.password);
        $("#save").prop("checked", true);
    }
    $(document).ready(function () {
        $("#login").click(function () {
            $("#login").prop("disabled", true);
            var phone = $("[name='phone']").val();
            var password = $("[name='password']").val();
            if ($("#save").prop("checked") == true) {
                localStorage.phone = phone;
                localStorage.password = password;
                localStorage.rememberMe = 1;
            } else {
                localStorage.phone = null;
                localStorage.password = null;
                localStorage.rememberMe = 0;
            }
            AsyncPost("/user/login", {phone: phone, password: password}, function (data) {
                localStorage.token=data;
                window.location.href = "./main.html";
            },function (message) {
                $("#login").prop("disabled", false);
            })
        });
    });
</script>
</body>
</html>
